import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)
// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}


  const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    redirect:"/user",
    component: () => import('../views/About.vue'),
    children:[
      {//用户
        path: '/user',
        name: 'User',
        component: () => import('../views/About/User'),
      },
      {//角色
        path: '/juese',
        name: 'Juese',
        component: () => import('../views/About/Juese'),
      },
      { //权限
        path: '/quanxian',
        name: 'Quanxian',
        component: () => import('../views/About/Quanxian'),
      },
      { //商品列表
        path: '/shoplist',
        name: 'Shoplist',
        component: () => import('../views/About/Shoplist'),
      },
      { //商品列表
        path: '/addgoods',
        name: 'addgoods',
        component: () => import('../views/About/addgoods'),
      },
      { //数据统计表
        path: '/shuju',
        name: 'Shuju',
        component: () => import('../views/About/Shuju'),
      },
      { //地图
        path: '/baidumap',
        name: 'BaiDuMap',
        component: () => import('../views/About/BaiDuMap'),
      },
      { //商品分类列表
        path: '/categories',
        name: 'categories',
        component: () => import('../views/About/categories'),
      },
      
    ]
  }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
